<template>
  <div class="wrapper" ref="wrapper">
    <div class="content">
      <slot></slot>
    </div>
  </div>
</template>

<script>
  import BScroll from 'better-scroll'
  export default {
    name: "Scroll",
    props:{
      handleScroll: Function,
      scrollX: {
        type: Boolean,
        default: false
      },
      scrollY: {
        type: Boolean,
        default: true
      },
      // 接收滚动视图的宽度
      width: {
        type: [String, Number],
        default: '100%'
      }
    },
    computed:{
      //计算最终宽度
      wrapWidth(){
        if(typeof this.width==='string'){
          return this.width
        }else {
          return this.width+'px'
        }
      }
    },
    mounted() {
        this.scroll=new BScroll(this.$refs.wrapper,{
          click:true,
          startX:0,
          scrollX:this.scrollX,
          scrollY:this.scrollY,
          eventPassthrough: this.scrollX?"vertical":"horizontal"
        })
    },
    methods:{
      // refresh(){
      //   this.scroll&&this.scroll.refresh()
      // }
    }
  }
</script>

<style scoped>
</style>